---
title: "Replication Material for 'Herold, Maik 2024: The impact of conspiracy belief on democratic culture: Evidence from Europe' (HKSMR)"
author: "MaikHerold"
date: "2024-10-27"
output: html_document
---

# -----------------------------------------
# -----------------------------------------
# setup

```{r clear, warning=FALSE}
rm(list = ls())
options(scipen = 999) 

```


# data

```{r}

POLAR22 <- read.csv("Data_CBEurope.csv")


```


# packages


```{r}

library(rmarkdown)
library(car)
library(tidyverse)

library(estimatr)

library(dplyr)
library(ggplot2)

library(jtools)
library(huxtable)

library(sandwich)
library(lmtest)
library(pscl)
library(margins)

library(sf)
library(rnaturalearth)
library(rnaturalearthdata)

```



# -----------------------------------------
# -----------------------------------------
# -----------------------------------------

# ++++++
# ANALYSES
# ++++++

# -----------------------------------------
# -----------------------------------------
# -----------------------------------------


# [DESCRIPTIVE]

### subset

```{r}


POLAR22_descript <- 
  subset(POLAR22, select=c(
                           
                           "cb_mig_num_resc",
                           "cb_covid_num_resc",

                           "country_factor",

                           "weight"))


POLAR22_descript_nasraus <- POLAR22_descript %>%
  drop_na()

```





### map: cb_mig_num_resc


```{r}

weighted_means <- POLAR22_descript_nasraus %>%
  group_by(country_factor) %>%
  summarise(weighted_mean = sum(cb_mig_num_resc * weight) / sum(weight))

print(weighted_means)

world <- ne_countries(scale = "medium", returnclass = "sf")
europe <- world %>% filter(continent == "Europe")

europe_weighted_means <- europe %>%
  left_join(weighted_means, by = c("name" = "country_factor"))


# plot
ggplot(data = europe_weighted_means) +
  geom_sf(aes(fill = weighted_mean), color = "black") +

  
  scale_fill_fermenter(
    palette = 12, 
    direction = 1,
    na.value = "white",
    breaks = seq(from = 0.3, to = 0.6, by = 0.02),
    guide = guide_colorbar(
      direction = "vertical",             
      title.position = "top",           
      label.position = "right",          
      barwidth = unit(0.4, "cm"),         
      barheight = unit(5, "cm"),         
      ticks = TRUE,                      
      )
    ) +
  
  theme_void() +
  
  labs(title = "Conspiracy belief: migration",
       #subtitle = "weighted means",
       #caption = "Data: Eurostat tec00115",
       fill = "weighted mean"
       ) +
  
  theme(
    legend.position = "right",
    #legend.justification = "top",
    #legend.box = "vertical",
    legend.spacing = unit(1, "cm"),
    legend.margin = margin(0, 0, 0, 10)
       ) +
  
  scale_x_continuous(limits = c(-10, 35)) +
  scale_y_continuous(limits = c(35, 70))


```


### map: cb_covid_num_resc


```{r}

weighted_means <- POLAR22_descript_nasraus %>%
  group_by(country_factor) %>%
  summarise(weighted_mean = sum(cb_covid_num_resc * weight) / sum(weight))

print(weighted_means)

world <- ne_countries(scale = "medium", returnclass = "sf")

europe <- world %>% filter(continent == "Europe")

europe_weighted_means <- europe %>%
  left_join(weighted_means, by = c("name" = "country_factor"))


# plot
ggplot(data = europe_weighted_means) +
  geom_sf(aes(fill = weighted_mean), color = "black") +

  scale_fill_fermenter(
    palette = 12, 
    direction = 1,
    na.value = "white",
    breaks = seq(from = 0.32, to = 0.7, by = 0.04),
    guide = guide_colorbar(
      direction = "vertical",             
      title.position = "top",           
      label.position = "right",          
      barwidth = unit(0.4, "cm"),         
      barheight = unit(5, "cm"),         
      ticks = TRUE,                    
      )
    ) +
  
  theme_void() +
  
  labs(title = "Conspiracy belief: Covid-19",
       #subtitle = "weighted means",
       #caption = "Data: Eurostat tec00115",
       fill = "weighted mean"
       ) +
  
  theme(
    legend.position = "right",
    #legend.justification = "top",
    #legend.box = "vertical",
    legend.spacing = unit(1, "cm"),
    legend.margin = margin(0, 0, 0, 10)
       ) +
  
  scale_x_continuous(limits = c(-10, 35)) +
  scale_y_continuous(limits = c(35, 70))


```


```{r}



```



# -----------------------------------------
# -----------------------------------------
# -----------------------------------------




# [DEMOCRACY]


### subset



```{r}


POLAR22_dem <- 
  subset(POLAR22, select=c(
                           
                           "cb_mig_num_resc",
                           "cb_covid_num_resc",
                           
                           "polinterest_num",
                           "leftright_num",
    
                           "demzuf_allg_num_resc",
                           "demzuf_land_num_resc",
                           "INDEXmean_poltrust_7items_resc",
                           "INDEXmean_pop_9items3dim",
                           
                           "gender_1isfemale",
                           "age",
    
                           #"education_3grp",
                           "education_3grp_1islow",
                           "education_3grp_1ismed",
                           "education_3grp_1ishigh",
    
                           #"income_3grp",
                           "income_3grp_1islow",
                           "income_3grp_1ismed",
                           "income_3grp_1ishigh",
    
                           #"wohn_4grp",
                           "wohn_4grp_1iscity",
                           "wohn_4grp_1istown",
                           "wohn_4grp_1issuburb",
                           "wohn_4grp_1island",
    
                           
                           "country_factor",

                           "weight"))
                           


POLAR22_dem_nasraus <- POLAR22_dem %>%
  drop_na()



```




### model: cb_mig_num_resc ~ democracy



```{r}

#library(estimatr)

model_dem_mig <- lm_robust(cb_mig_num_resc ~ 
                  
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_dem_nasraus
                          , clusters = country_factor

                   )


summary(model_dem_mig)
```



### model: cb_covid_num_resc ~ democracy



```{r}
model_dem_covid <- lm_robust(cb_covid_num_resc ~ 
                  
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_dem_nasraus
                          , clusters = country_factor

                   )


summary(model_dem_covid)
```





### print table _all


```{r}

#library(jtools)
#library(huxtable)


result_tab <- export_summs(model_dem_mig, model_dem_covid,
              #scale = TRUE,
              #robust = TRUE,
              coefs = c(
               "Consider democracy to be important" = "demzuf_allg_num_resc",
               "Satisfaction with democracy" = "demzuf_land_num_resc",
               "Political trust" = "INDEXmean_poltrust_7items_resc",
               "Populism" = "INDEXmean_pop_9items3dim",
               "Political interest" = "polinterest_num",
               "Left-right self-positioning" = "leftright_num",
               "Gender (1 = female)" = "gender_1isfemale",
               "Age" = "age",
               "Education level (1 = medium)" = "education_3grp_1ismed",
               "Education level (1 = high)" = "education_3grp_1ishigh",
               "Income (1 = medium)" = "income_3grp_1ismed",
               "Income (1 = high)" = "income_3grp_1ishigh",
               "Place of residence (1 = rural)" = "wohn_4grp_1island",
               "Place of residence (1 = town)" = "wohn_4grp_1istown",
               "Place of residence (1 = suburb)" = "wohn_4grp_1issuburb",
               "Country fixed-effects" = "gender_1isfemale",
               "Constant" = "(Intercept)"
               ),
              model.names = c("Conspiracy belief: immigration", "Conspiracy belief: Covid-19")
             )


print(result_tab)

```

### ---------


### [PLOTS: PREDICTIONS]


#### model: cb_mig_num_resc ~ democracy [lm function, no clustered rob SE]

```{r}

model_dem_mig <- lm(cb_mig_num_resc ~ 
                  
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_dem_nasraus

                   )

summary(model_dem_covid)

```




#### model: cb_covid_num_resc ~ democracy [lm function, no clustered rob SE]

```{r}

model_dem_covid <- lm(cb_covid_num_resc ~ 
                  
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_dem_nasraus

                   )


summary(model_dem_covid)

```






#### create constant_df


```{r}

constant_df1_demzuf <- data.frame(demzuf_land_num_resc = seq(0, 1, by = 0.01),
                          
                      #demzuf_land_num_resc = mean(POLAR22_dem_nasraus$demzuf_land_num_resc),
                      demzuf_allg_num_resc = mean(POLAR22_dem_nasraus$demzuf_allg_num_resc),
                      INDEXmean_poltrust_7items_resc = mean(POLAR22_dem_nasraus$INDEXmean_poltrust_7items_resc),
                      INDEXmean_pop_9items3dim = mean(POLAR22_dem_nasraus$INDEXmean_pop_9items3dim),
                      
                      leftright_num = mean(POLAR22_dem_nasraus$leftright_num),
                      polinterest_num = mean(POLAR22_dem_nasraus$polinterest_num),
                      
                      gender_1isfemale = mean(POLAR22_dem_nasraus$gender_1isfemale),
                      age = mean(POLAR22_dem_nasraus$age),
                      #education_3grp_1islow = mean(POLAR22_dem_nasraus$education_3grp_1islow),
                      education_3grp_1ismed = mean(POLAR22_dem_nasraus$education_3grp_1ismed),
                      education_3grp_1ishigh = mean(POLAR22_dem_nasraus$education_3grp_1ishigh),
                      #income_3grp_1islow = mean(POLAR22_dem_nasraus$income_3grp_1islow),
                      income_3grp_1ismed = mean(POLAR22_dem_nasraus$income_3grp_1ismed),
                      income_3grp_1ishigh = mean(POLAR22_dem_nasraus$income_3grp_1ishigh),
                      #wohn_4grp_1iscity = mean(POLAR22_dem_nasraus$wohn_4grp_1iscity),
                      wohn_4grp_1issuburb = mean(POLAR22_dem_nasraus$wohn_4grp_1issuburb),
                      wohn_4grp_1istown = mean(POLAR22_dem_nasraus$wohn_4grp_1istown),
                      wohn_4grp_1island = mean(POLAR22_dem_nasraus$wohn_4grp_1island),
                      
                      country_factor = "Germany"
                      
                      )



constant_df2_poltrust <- data.frame(INDEXmean_poltrust_7items_resc = seq(0, 1, by = 0.01),
                          
                      demzuf_land_num_resc = mean(POLAR22_dem_nasraus$demzuf_land_num_resc),
                      demzuf_allg_num_resc = mean(POLAR22_dem_nasraus$demzuf_allg_num_resc),
                      #INDEXmean_poltrust_7items_resc = mean(POLAR22_dem_nasraus$INDEXmean_poltrust_7items_resc),
                      INDEXmean_pop_9items3dim = mean(POLAR22_dem_nasraus$INDEXmean_pop_9items3dim),
                      
                      leftright_num = mean(POLAR22_dem_nasraus$leftright_num),
                      polinterest_num = mean(POLAR22_dem_nasraus$polinterest_num),
                      
                      gender_1isfemale = mean(POLAR22_dem_nasraus$gender_1isfemale),
                      age = mean(POLAR22_dem_nasraus$age),
                      #education_3grp_1islow = mean(POLAR22_dem_nasraus$education_3grp_1islow),
                      education_3grp_1ismed = mean(POLAR22_dem_nasraus$education_3grp_1ismed),
                      education_3grp_1ishigh = mean(POLAR22_dem_nasraus$education_3grp_1ishigh),
                      #income_3grp_1islow = mean(POLAR22_dem_nasraus$income_3grp_1islow),
                      income_3grp_1ismed = mean(POLAR22_dem_nasraus$income_3grp_1ismed),
                      income_3grp_1ishigh = mean(POLAR22_dem_nasraus$income_3grp_1ishigh),
                      #wohn_4grp_1iscity = mean(POLAR22_dem_nasraus$wohn_4grp_1iscity),
                      wohn_4grp_1issuburb = mean(POLAR22_dem_nasraus$wohn_4grp_1issuburb),
                      wohn_4grp_1istown = mean(POLAR22_dem_nasraus$wohn_4grp_1istown),
                      wohn_4grp_1island = mean(POLAR22_dem_nasraus$wohn_4grp_1island),
                      
                      country_factor = "Germany"
                      
                      )


constant_df3_pop <- data.frame(INDEXmean_pop_9items3dim = seq(0, 1, by = 0.01),
                          
                      demzuf_land_num_resc = mean(POLAR22_dem_nasraus$demzuf_land_num_resc),
                      demzuf_allg_num_resc = mean(POLAR22_dem_nasraus$demzuf_allg_num_resc),
                      INDEXmean_poltrust_7items_resc = mean(POLAR22_dem_nasraus$INDEXmean_poltrust_7items_resc),
                      #INDEXmean_pop_9items3dim = mean(POLAR22_dem_nasraus$INDEXmean_pop_9items3dim),
                      
                      leftright_num = mean(POLAR22_dem_nasraus$leftright_num),
                      polinterest_num = mean(POLAR22_dem_nasraus$polinterest_num),
                      
                      gender_1isfemale = mean(POLAR22_dem_nasraus$gender_1isfemale),
                      age = mean(POLAR22_dem_nasraus$age),
                      #education_3grp_1islow = mean(POLAR22_dem_nasraus$education_3grp_1islow),
                      education_3grp_1ismed = mean(POLAR22_dem_nasraus$education_3grp_1ismed),
                      education_3grp_1ishigh = mean(POLAR22_dem_nasraus$education_3grp_1ishigh),
                      #income_3grp_1islow = mean(POLAR22_dem_nasraus$income_3grp_1islow),
                      income_3grp_1ismed = mean(POLAR22_dem_nasraus$income_3grp_1ismed),
                      income_3grp_1ishigh = mean(POLAR22_dem_nasraus$income_3grp_1ishigh),
                      #wohn_4grp_1iscity = mean(POLAR22_dem_nasraus$wohn_4grp_1iscity),
                      wohn_4grp_1issuburb = mean(POLAR22_dem_nasraus$wohn_4grp_1issuburb),
                      wohn_4grp_1istown = mean(POLAR22_dem_nasraus$wohn_4grp_1istown),
                      wohn_4grp_1island = mean(POLAR22_dem_nasraus$wohn_4grp_1island),
                      
                      country_factor = "Germany"
                      
                      )



constant_df4_demzuf <- data.frame(demzuf_allg_num_resc = seq(0, 1, by = 0.01),
                          
                      demzuf_land_num_resc = mean(POLAR22_dem_nasraus$demzuf_land_num_resc),
                      #demzuf_allg_num_resc = mean(POLAR22_dem_nasraus$demzuf_allg_num_resc),
                      INDEXmean_poltrust_7items_resc = mean(POLAR22_dem_nasraus$INDEXmean_poltrust_7items_resc),
                      INDEXmean_pop_9items3dim = mean(POLAR22_dem_nasraus$INDEXmean_pop_9items3dim),
                      
                      leftright_num = mean(POLAR22_dem_nasraus$leftright_num),
                      polinterest_num = mean(POLAR22_dem_nasraus$polinterest_num),
                      
                      gender_1isfemale = mean(POLAR22_dem_nasraus$gender_1isfemale),
                      age = mean(POLAR22_dem_nasraus$age),
                      #education_3grp_1islow = mean(POLAR22_dem_nasraus$education_3grp_1islow),
                      education_3grp_1ismed = mean(POLAR22_dem_nasraus$education_3grp_1ismed),
                      education_3grp_1ishigh = mean(POLAR22_dem_nasraus$education_3grp_1ishigh),
                      #income_3grp_1islow = mean(POLAR22_dem_nasraus$income_3grp_1islow),
                      income_3grp_1ismed = mean(POLAR22_dem_nasraus$income_3grp_1ismed),
                      income_3grp_1ishigh = mean(POLAR22_dem_nasraus$income_3grp_1ishigh),
                      #wohn_4grp_1iscity = mean(POLAR22_dem_nasraus$wohn_4grp_1iscity),
                      wohn_4grp_1issuburb = mean(POLAR22_dem_nasraus$wohn_4grp_1issuburb),
                      wohn_4grp_1istown = mean(POLAR22_dem_nasraus$wohn_4grp_1istown),
                      wohn_4grp_1island = mean(POLAR22_dem_nasraus$wohn_4grp_1island),
                      
                      country_factor = "Germany"
                      
                      )



```




#### predictions: mig


```{r}

# prediction 1

predicted_df1_demzuf <- data.frame(demzuf_land_num_resc = constant_df1_demzuf$demzuf_land_num_resc)

  predicted_df1_demzuf$predicted_cb_mig_num_resc__demzuf <- predict(model_dem_mig, newdata = constant_df1_demzuf, interval = "confidence")[, "fit"]
  predicted_df1_demzuf$lwr_cb_mig_num_resc__demzuf <- predict(model_dem_mig, newdata = constant_df1_demzuf, interval = "confidence")[, "lwr"]
  predicted_df1_demzuf$upr_cb_mig_num_resc__demzuf <- predict(model_dem_mig, newdata = constant_df1_demzuf, interval = "confidence")[, "upr"]


  
# prediction 2  
  
predicted_df2_poltrust <- data.frame(INDEXmean_poltrust_7items_resc = constant_df2_poltrust$INDEXmean_poltrust_7items_resc)

  predicted_df2_poltrust$predicted_cb_mig_num_resc__poltrust <- predict(model_dem_mig, newdata = constant_df2_poltrust, interval = "confidence")[, "fit"]
  predicted_df2_poltrust$lwr_cb_mig_num_resc__poltrust <- predict(model_dem_mig, newdata = constant_df2_poltrust, interval = "confidence")[, "lwr"]
  predicted_df2_poltrust$upr_cb_mig_num_resc__poltrust <- predict(model_dem_mig, newdata = constant_df2_poltrust, interval = "confidence")[, "upr"]


  
# prediction 3
  
predicted_df3_pop <- data.frame(INDEXmean_pop_9items3dim = constant_df3_pop$INDEXmean_pop_9items3dim)

  predicted_df3_pop$predicted_cb_mig_num_resc__pop <- predict(model_dem_mig, newdata = constant_df3_pop, interval = "confidence")[, "fit"]
  predicted_df3_pop$lwr_cb_mig_num_resc__pop <- predict(model_dem_mig, newdata = constant_df3_pop, interval = "confidence")[, "lwr"]
  predicted_df3_pop$upr_cb_mig_num_resc__pop <- predict(model_dem_mig, newdata = constant_df3_pop, interval = "confidence")[, "upr"]

  
# prediction 4

predicted_df4_demzuf <- data.frame(demzuf_allg_num_resc = constant_df4_demzuf$demzuf_allg_num_resc)

predicted_df4_demzuf$predicted_cb_mig_num_resc__demzuf2 <- predict(model_dem_mig, newdata = constant_df4_demzuf, interval = "confidence")[, "fit"]
  predicted_df4_demzuf$lwr_cb_mig_num_resc__demzuf2 <- predict(model_dem_mig, newdata = constant_df4_demzuf, interval = "confidence")[, "lwr"]
  predicted_df4_demzuf$upr_cb_mig_num_resc__demzuf2 <- predict(model_dem_mig, newdata = constant_df4_demzuf, interval = "confidence")[, "upr"]



```



#### plot mig

```{r}
cb_mig___democracy_all <-
 
 
ggplot() +


  geom_line(
      data = predicted_df1_demzuf,
      aes(
        x = demzuf_land_num_resc,
        y = predicted_cb_mig_num_resc__demzuf,
        linetype = "longdash"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df1_demzuf,
      aes(
        x = demzuf_land_num_resc,
        ymin = lwr_cb_mig_num_resc__demzuf,
        ymax = upr_cb_mig_num_resc__demzuf
      ),
      fill = "grey", 
      alpha = 0.3
    ) +
  
  
  geom_line(
      data = predicted_df4_demzuf,
      aes(
        x = demzuf_allg_num_resc,
        y = predicted_cb_mig_num_resc__demzuf2,
        linetype = "solid"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df4_demzuf,
      aes(
        x = demzuf_allg_num_resc,
        ymin = lwr_cb_mig_num_resc__demzuf2,
        ymax = upr_cb_mig_num_resc__demzuf2
      ),
      fill = "grey", 
      alpha = 0.3
    ) +
  

  geom_line(
      data = predicted_df2_poltrust,
      aes(
        x = INDEXmean_poltrust_7items_resc,
        y = predicted_cb_mig_num_resc__poltrust,
        linetype = "dotdash"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df2_poltrust,
      aes(
        x = INDEXmean_poltrust_7items_resc,
        ymin = lwr_cb_mig_num_resc__poltrust,
        ymax = upr_cb_mig_num_resc__poltrust
      ),
      fill = "grey", 
      alpha = 0.3
    ) +

  
  geom_line(
      data = predicted_df3_pop,
      aes(
        x = INDEXmean_pop_9items3dim,
        y = predicted_cb_mig_num_resc__pop,
        linetype = "dotted"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df3_pop,
      aes(
        x = INDEXmean_pop_9items3dim,
        ymin = lwr_cb_mig_num_resc__pop,
        ymax = upr_cb_mig_num_resc__pop
      ),
      fill = "grey", 
      alpha = 0.3
    ) +
  
  
  
  labs(
        x = " ", 
        y = "Predicted conspiracy belief (Immigration)",
        linetype = "Variable"
        ) +
  
  
  
  scale_linetype_manual(
    values = c("solid", "longdash", "dotdash", "dotted"),
    labels = c("Political trust", "Populism", "Satisfaction with democracy in country", "Consider democracy to be important"), 
    guide = guide_legend()
  ) +


  scale_x_continuous(
        breaks = seq(0, 1, by = 0.1), 
        labels = seq(0, 1, by = 0.1)
        ) +
  
  scale_y_continuous(
        limits = c(0.3, 0.8), 
        breaks = seq(0, 1, by = 0.1)  
        ) +
  
  
  #ggtitle("Europe") +
  theme(plot.title = element_text(hjust = 0.5)) +  
  theme(plot.margin = margin(t = 20, r = 20, b = 20, l = 20)) +  
  
  theme_minimal() +
    
  theme(
      axis.text.x = element_text(margin = margin(b = 10)),  
      axis.text.y = element_text(margin = margin(l = 10))    
        )

cb_mig___democracy_all

```



#### predictions: covid


```{r}

# prediction 1

predicted_df1_demzuf <- data.frame(demzuf_land_num_resc = constant_df1_demzuf$demzuf_land_num_resc)

  predicted_df1_demzuf$predicted_cb_covid_num_resc__demzuf <- predict(model_dem_covid, newdata = constant_df1_demzuf, interval = "confidence")[, "fit"]
  predicted_df1_demzuf$lwr_cb_covid_num_resc__demzuf <- predict(model_dem_covid, newdata = constant_df1_demzuf, interval = "confidence")[, "lwr"]
  predicted_df1_demzuf$upr_cb_covid_num_resc__demzuf <- predict(model_dem_covid, newdata = constant_df1_demzuf, interval = "confidence")[, "upr"]


  
# prediction 2  
  
predicted_df2_poltrust <- data.frame(INDEXmean_poltrust_7items_resc = constant_df2_poltrust$INDEXmean_poltrust_7items_resc)

  predicted_df2_poltrust$predicted_cb_covid_num_resc__poltrust <- predict(model_dem_covid, newdata = constant_df2_poltrust, interval = "confidence")[, "fit"]
  predicted_df2_poltrust$lwr_cb_covid_num_resc__poltrust <- predict(model_dem_covid, newdata = constant_df2_poltrust, interval = "confidence")[, "lwr"]
  predicted_df2_poltrust$upr_cb_covid_num_resc__poltrust <- predict(model_dem_covid, newdata = constant_df2_poltrust, interval = "confidence")[, "upr"]


  
# prediction 3
  
predicted_df3_pop <- data.frame(INDEXmean_pop_9items3dim = constant_df3_pop$INDEXmean_pop_9items3dim)

  predicted_df3_pop$predicted_cb_covid_num_resc__pop <- predict(model_dem_covid, newdata = constant_df3_pop, interval = "confidence")[, "fit"]
  predicted_df3_pop$lwr_cb_covid_num_resc__pop <- predict(model_dem_covid, newdata = constant_df3_pop, interval = "confidence")[, "lwr"]
  predicted_df3_pop$upr_cb_covid_num_resc__pop <- predict(model_dem_covid, newdata = constant_df3_pop, interval = "confidence")[, "upr"]

  
# prediction 4

predicted_df4_demzuf <- data.frame(demzuf_allg_num_resc = constant_df4_demzuf$demzuf_allg_num_resc)

predicted_df4_demzuf$predicted_cb_covid_num_resc__demzuf2 <- predict(model_dem_covid, newdata = constant_df4_demzuf, interval = "confidence")[, "fit"]
  predicted_df4_demzuf$lwr_cb_covid_num_resc__demzuf2 <- predict(model_dem_covid, newdata = constant_df4_demzuf, interval = "confidence")[, "lwr"]
  predicted_df4_demzuf$upr_cb_covid_num_resc__demzuf2 <- predict(model_dem_covid, newdata = constant_df4_demzuf, interval = "confidence")[, "upr"]



```






#### plot: covid

```{r}
cb_covid___democracy_all <-
 
 
ggplot() +


  geom_line(
      data = predicted_df1_demzuf,
      aes(
        x = demzuf_land_num_resc,
        y = predicted_cb_covid_num_resc__demzuf,
        linetype = "longdash"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df1_demzuf,
      aes(
        x = demzuf_land_num_resc,
        ymin = lwr_cb_covid_num_resc__demzuf,
        ymax = upr_cb_covid_num_resc__demzuf
      ),
      fill = "grey", 
      alpha = 0.3
    ) +
  
  
  geom_line(
      data = predicted_df4_demzuf,
      aes(
        x = demzuf_allg_num_resc,
        y = predicted_cb_covid_num_resc__demzuf2,
        linetype = "solid"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df4_demzuf,
      aes(
        x = demzuf_allg_num_resc,
        ymin = lwr_cb_covid_num_resc__demzuf2,
        ymax = upr_cb_covid_num_resc__demzuf2
      ),
      fill = "grey", 
      alpha = 0.3
    ) +
  

  geom_line(
      data = predicted_df2_poltrust,
      aes(
        x = INDEXmean_poltrust_7items_resc,
        y = predicted_cb_covid_num_resc__poltrust,
        linetype = "dotdash"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df2_poltrust,
      aes(
        x = INDEXmean_poltrust_7items_resc,
        ymin = lwr_cb_covid_num_resc__poltrust,
        ymax = upr_cb_covid_num_resc__poltrust
      ),
      fill = "grey", 
      alpha = 0.3
    ) +

  
  geom_line(
      data = predicted_df3_pop,
      aes(
        x = INDEXmean_pop_9items3dim,
        y = predicted_cb_covid_num_resc__pop,
        linetype = "dotted"
        ),
      color = "black",
      size = 0.5
            ) +
  
  geom_ribbon(
      data = predicted_df3_pop,
      aes(
        x = INDEXmean_pop_9items3dim,
        ymin = lwr_cb_covid_num_resc__pop,
        ymax = upr_cb_covid_num_resc__pop
      ),
      fill = "grey", 
      alpha = 0.3
    ) +
  
  
  
  labs(
        x = " ", 
        y = "Predicted conspiracy belief (Covid-19)",
        linetype = "Variable"
        ) +
  
  
  # legende
  
  scale_linetype_manual(
    values = c("solid", "longdash", "dotdash", "dotted"),  
    labels = c("Political trust", "Populism", "Satisfaction with democracy in country", "Consider democracy to be important"),
    guide = guide_legend()
  ) +


  scale_x_continuous(
        breaks = seq(0, 1, by = 0.1), 
        labels = seq(0, 1, by = 0.1)
        ) +
  
  scale_y_continuous(
        limits = c(0.3, 0.9),
        breaks = seq(0, 1, by = 0.1)
        ) +
  
  

  #ggtitle("Europe") +
  theme(plot.title = element_text(hjust = 0.5)) +  
  theme(plot.margin = margin(t = 20, r = 20, b = 20, l = 20)) +  
  
  theme_minimal() +
    
  theme(
      axis.text.x = element_text(margin = margin(b = 10)), 
      axis.text.y = element_text(margin = margin(l = 10)) 
        )

cb_covid___democracy_all

```




# -----------------------------------------
# -----------------------------------------
# -----------------------------------------



# [EFFICACY]


## subset



```{r}


POLAR22_eff <- 
  subset(POLAR22, select=c(
                           "cb_mig_num_resc",
                           "cb_covid_num_resc",

                           "peff_ext_num_resc",
                           "peff_int_num_resc",
                           
                           "polinterest_num",
                           "leftright_num",
    
                           "demzuf_allg_num_resc",
                           "demzuf_land_num_resc",
                           "INDEXmean_poltrust_7items_resc",
                           "INDEXmean_pop_9items3dim",
                           
                           "gender_1isfemale",
                           "age",
    
                           #"education_3grp",
                           "education_3grp_1islow",
                           "education_3grp_1ismed",
                           "education_3grp_1ishigh",
    
                           #"income_3grp",
                           "income_3grp_1islow",
                           "income_3grp_1ismed",
                           "income_3grp_1ishigh",
    
                           #"wohn_4grp",
                           "wohn_4grp_1iscity",
                           "wohn_4grp_1istown",
                           "wohn_4grp_1issuburb",
                           "wohn_4grp_1island",
    
                           "country_factor",

                           "weight"))
                           

POLAR22_eff_nasraus <- POLAR22_eff %>%
  drop_na()



```




## model_peff_ext_num_resc


```{r}
#library(estimatr)

model_peff_ext_num_resc <- lm_robust(peff_ext_num_resc ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_eff_nasraus
                          , clusters = country_factor

                       )

summary(model_peff_ext_num_resc)


```



## model_peff_int_num_resc


```{r}
#library(estimatr)

model_peff_int_num_resc <- lm_robust(peff_int_num_resc ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num

                           + country_factor
                           
                          , data = POLAR22_eff_nasraus
                          , clusters = country_factor

                       )

summary(model_peff_int_num_resc)


```




## print table _all


```{r}

#library(jtools)
#library(huxtable)


result_tab <- export_summs(model_peff_ext_num_resc, model_peff_int_num_resc,
              #scale = TRUE,
              #robust = TRUE,
              coefs = c(
               "Conspiracy belief: immigration" = "cb_mig_num_resc",
               "Conspiracy belief: Covid-19" = "cb_covid_num_resc",
               "Political interest" = "polinterest_num",
               "Left-right self-positioning" = "leftright_num",
               "Consider democracy to be important" = "demzuf_allg_num_resc",
               "Satisfaction with democracy" = "demzuf_land_num_resc",
               "Political trust" = "INDEXmean_poltrust_7items_resc",
               "Populism" = "INDEXmean_pop_9items3dim",
               "Gender (1 = female)" = "gender_1isfemale",
               "Age" = "age",
               "Education level (1 = medium)" = "education_3grp_1ismed",
               "Education level (1 = high)" = "education_3grp_1ishigh",
               "Income (1 = medium)" = "income_3grp_1ismed",
               "Income (1 = high)" = "income_3grp_1ishigh",
               "Place of residence (1 = rural)" = "wohn_4grp_1island",
               "Place of residence (1 = town)" = "wohn_4grp_1istown",
               "Place of residence (1 = suburb)" = "wohn_4grp_1issuburb",
               "Country fixed-effects" = "gender_1isfemale",
               "Constant" = "(Intercept)"
               ),
              model.names = c("External political efficacy", "Internal political efficacy")
             )


print(result_tab)

```





# -----------------------------------------
# -----------------------------------------
# -----------------------------------------


# [VOTING INTENTION]


## subset

```{r}


POLAR22_subset_model <- 
  subset(POLAR22, select=c(
                          
                           "cb_mig_num_resc",
                           "cb_covid_num_resc",
                           
                           "polinterest_num",
                           "leftright_num",
    
                           "demzuf_allg_num_resc",
                           "demzuf_land_num_resc",
                           "INDEXmean_poltrust_7items_resc",
                           "INDEXmean_pop_9items3dim",
                           
                           "party_1islex",
                           "party_1issozdem",
                           "party_1isgreen",
                           "party_1islib",
                           "party_1iscons",
                           "party_1isrex",

                           "gender_1isfemale",
                           "age",
    
                           #"education_3grp",
                           "education_3grp_1islow",
                           "education_3grp_1ismed",
                           "education_3grp_1ishigh",
    
                           #"income_3grp",
                           "income_3grp_1islow",
                           "income_3grp_1ismed",
                           "income_3grp_1ishigh",
    
                           #"wohn_4grp",
                           "wohn_4grp_1iscity",
                           "wohn_4grp_1istown",
                           "wohn_4grp_1issuburb",
                           "wohn_4grp_1island",
    
                           "country_factor",

                           "weight"))
                           


POLAR22_subset_model_nasraus <- POLAR22_subset_model %>%
  drop_na()



```


## model_party_rex ~ cb_mig/cb_covid

```{r}

model_party_rex <- glm(party_1isrex ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_party_rex)


```


## model_party_cons ~ cb_mig/cb_covid

```{r}

model_party_cons <- glm(party_1iscons ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_party_cons)


```




## model_party_lib ~ cb_mig/cb_covid

```{r}

model_party_lib <- glm(party_1islib ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_party_lib)


```



## model_party_sozdem ~ cb_mig/cb_covid

```{r}

model_party_sozdem <- glm(party_1issozdem ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_party_sozdem)


```



## model_party_green ~ cb_mig/cb_covid

```{r}

model_party_green <- glm(party_1isgreen ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           + polinterest_num
                           + leftright_num
    
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_party_green)


```



## model_party_lex ~ cb_mig/cb_covid

```{r}

model_party_lex <- glm(party_1islex ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_party_lex)


```







## clustered robust SE


```{r}

#library(sandwich)

clust_vcov_party_rex <- vcovCL(model_party_rex, cluster = ~country_factor)

clust_vcov_party_cons <- vcovCL(model_party_cons, cluster = ~country_factor)

clust_vcov_party_lib <- vcovCL(model_party_lib, cluster = ~country_factor)

clust_vcov_party_sozdem <- vcovCL(model_party_sozdem, cluster = ~country_factor)

clust_vcov_party_green <- vcovCL(model_party_green, cluster = ~country_factor)

clust_vcov_party_lex <- vcovCL(model_party_lex, cluster = ~country_factor)

```


```{r}

#library(lmtest)

model_party_rex_clust <- coeftest(model_party_rex, vcov = clust_vcov_party_rex)

model_party_cons_clust <- coeftest(model_party_cons, vcov = clust_vcov_party_cons)

model_party_lib_clust <- coeftest(model_party_lib, vcov = clust_vcov_party_lib)

model_party_sozdem_clust <- coeftest(model_party_sozdem, vcov = clust_vcov_party_sozdem)

model_party_green_clust <- coeftest(model_party_green, vcov = clust_vcov_party_green)

model_party_lex_clust <- coeftest(model_party_lex, vcov = clust_vcov_party_lex)


```






## print table _all

```{r}

#library(jtools)
#library(huxtable)


result_tab <- export_summs(model_party_lex_clust, model_party_green_clust, model_party_sozdem_clust, model_party_lib_clust, model_party_cons_clust, model_party_rex_clust,
              #scale = TRUE,
              #robust = TRUE,
              coefs = c(
               "Conspiracy belief: immigration" = "cb_mig_num_resc",
               "Conspiracy belief: Covid-19" = "cb_covid_num_resc",
               "Political interest" = "polinterest_num",
               "Left-right self-positioning" = "leftright_num",
               "Consider democracy to be important" = "demzuf_allg_num_resc",
               "Satisfaction with democracy" = "demzuf_land_num_resc",
               "Political trust" = "INDEXmean_poltrust_7items_resc",
               "Populism" = "INDEXmean_pop_9items3dim",
               "Gender (1 = female)" = "gender_1isfemale",
               "Age" = "age",
               "Education level (1 = medium)" = "education_3grp_1ismed",
               "Education level (1 = high)" = "education_3grp_1ishigh",
               "Income (1 = medium)" = "income_3grp_1ismed",
               "Income (1 = high)" = "income_3grp_1ishigh",
               "Place of residence (1 = rural)" = "wohn_4grp_1island",
               "Place of residence (1 = town)" = "wohn_4grp_1istown",
               "Place of residence (1 = suburb)" = "wohn_4grp_1issuburb",
               "Country fixed-effects" = "gender_1isfemale",
               "Constant" = "(Intercept)"
               ),
              model.names = c("Left/far-left", "Green", "Socialdemocratic", "Liberal", "Conservative", "Right/far-right")
             )


print(result_tab)

```


## pseudo-r2


```{r}

#library(pscl)

pseudo_r2_model_party_lex <- pR2(model_party_lex)
pseudo_r2_model_party_green <- pR2(model_party_green)
pseudo_r2_model_party_sozdem <- pR2(model_party_sozdem)
pseudo_r2_model_party_lib <- pR2(model_party_lib)
pseudo_r2_model_party_cons <- pR2(model_party_cons)
pseudo_r2_model_party_rex <- pR2(model_party_rex)

#print(pseudo_r2_model_party_lex)

```



## AME


```{r}
#library(margins)

var_list <- c("cb_mig_num_resc", "cb_covid_num_resc")

```


```{r}

margins(model_party_rex
        , vcov = clust_vcov_party_rex
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```

```{r}

margins(model_party_cons
        , vcov = clust_vcov_party_cons
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_party_lib
        , vcov = clust_vcov_party_lib
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_party_sozdem
        , vcov = clust_vcov_party_sozdem
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_party_green
        , vcov = clust_vcov_party_green
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_party_lex
        , vcov = clust_vcov_party_lex
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```






# -----------------------------------------
# -----------------------------------------
# -----------------------------------------



# PARTICIPATION

### subset


```{r}


POLAR22_subset_model <- 
  subset(POLAR22, select=c(
                          
                           "cb_mig_num_resc",
                           "cb_covid_num_resc",
                           
                           "polinterest_num",
                           "leftright_num",
    
                           "demzuf_allg_num_resc",
                           "demzuf_land_num_resc",
                           "INDEXmean_poltrust_7items_resc",
                           "INDEXmean_pop_9items3dim",
                           
                           "polactiv_1ismeing_num",
                           "polactiv_1isdisk_num",
                           "polactiv_1issozmedia_num",
                           "polactiv_1isparty_num",
                           "polactiv_1iswear_num",
                           "polactiv_1iscontact_num",
                           "polactiv_1isdemo_num",
                           "polactiv_1ispetit_num",
                           "polactiv_1iselec_num",
                           "polactiv_1isboyc_num",
                           "polactiv_1isnothing_num",
                           
                           "gender_1isfemale",
                           "age",
    
                           #"education_3grp",
                           "education_3grp_1islow",
                           "education_3grp_1ismed",
                           "education_3grp_1ishigh",
    
                           #"income_3grp",
                           "income_3grp_1islow",
                           "income_3grp_1ismed",
                           "income_3grp_1ishigh",
    
                           #"wohn_4grp",
                           "wohn_4grp_1iscity",
                           "wohn_4grp_1istown",
                           "wohn_4grp_1issuburb",
                           "wohn_4grp_1island",
    
                           "country_factor",

                           "weight"))
                           

POLAR22_subset_model_nasraus <- POLAR22_subset_model %>%
  drop_na()



```




### model_polactiv_1ismeing ~ cb_mig/cb_covid


```{r}

model_polactiv_1ismeing <- glm(polactiv_1ismeing_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1ismeing)


```


### model_polactiv_1isdisk ~ cb_mig/cb_covid


```{r}

model_polactiv_1isdisk <- glm(polactiv_1isdisk_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1isdisk)


```



### model_polactiv_1issozmedia ~ cb_mig/cb_covid



```{r}

model_polactiv_1issozmedia <- glm(polactiv_1issozmedia_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1issozmedia)


```



### model_polactiv_1isparty ~ cb_mig/cb_covid



```{r}

model_polactiv_1isparty <- glm(polactiv_1isparty_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1isparty)


```



### model_polactiv_1iswear ~ cb_mig/cb_covid


```{r}

model_polactiv_1iswear <- glm(polactiv_1iswear_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1iswear)


```



### model_polactiv_1iscontact ~ cb_mig/cb_covid



```{r}

model_polactiv_1iscontact <- glm(polactiv_1iscontact_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1iscontact)


```



### model_polactiv_1isdemo ~ cb_mig/cb_covid


```{r}

model_polactiv_1isdemo <- glm(polactiv_1isdemo_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1isdemo)


```



### model_polactiv_1ispetit ~ cb_mig/cb_covid


```{r}

model_polactiv_1ispetit <- glm(polactiv_1ispetit_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1ispetit)


```



### model_polactiv_1iselec ~ cb_mig/cb_covid


```{r}

model_polactiv_1iselec <- glm(polactiv_1iselec_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1iselec)


```



### model_polactiv_1isboyc ~ cb_mig/cb_covid




```{r}

model_polactiv_1isboyc <- glm(polactiv_1isboyc_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1isboyc)


```



### model_polactiv_1isnothing ~ cb_mig/cb_covid


```{r}

model_polactiv_1isnothing <- glm(polactiv_1isnothing_num ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                       
                           + gender_1isfemale
                           + age
                           + I(age^2)
    
                           #+ education_3grp
                           #+ education_3grp_1islow
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
    
                           #+ income_3grp
                           #+ income_3grp_1islow
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
    
                           #+ wohn_4grp
                           #+ wohn_4grp_1iscity
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
               
                           #+ polinterest
                           + polinterest_num
                           + leftright_num
    
                           + country_factor
                           
                          , data = POLAR22_subset_model_nasraus
                          , family = binomial()

                       )

summary(model_polactiv_1isnothing)


```




### clustered robust SE


```{r}

#library(sandwich)

clust_vcov_polactiv_1ismeing <- vcovCL(model_polactiv_1ismeing, cluster = ~country_factor)

clust_vcov_polactiv_1isdisk <- vcovCL(model_polactiv_1isdisk, cluster = ~country_factor)

clust_vcov_polactiv_1issozmedia <- vcovCL(model_polactiv_1issozmedia, cluster = ~country_factor)

clust_vcov_polactiv_1isparty <- vcovCL(model_polactiv_1isparty, cluster = ~country_factor)

clust_vcov_polactiv_1iswear <- vcovCL(model_polactiv_1iswear, cluster = ~country_factor)

clust_vcov_polactiv_1iscontact <- vcovCL(model_polactiv_1iscontact, cluster = ~country_factor)

clust_vcov_polactiv_1isdemo <- vcovCL(model_polactiv_1isdemo, cluster = ~country_factor)

clust_vcov_polactiv_1ispetit <- vcovCL(model_polactiv_1ispetit, cluster = ~country_factor)

clust_vcov_polactiv_1iselec <- vcovCL(model_polactiv_1iselec, cluster = ~country_factor)

clust_vcov_polactiv_1isboyc <- vcovCL(model_polactiv_1isboyc, cluster = ~country_factor)

clust_vcov_polactiv_1isnothing <- vcovCL(model_polactiv_1isnothing, cluster = ~country_factor)

```


```{r}

#library(lmtest)

model_polactiv_1ismeing_clust <- coeftest(model_polactiv_1ismeing, vcov = clust_vcov_polactiv_1ismeing)

model_polactiv_1isdisk_clust <- coeftest(model_polactiv_1isdisk, vcov = clust_vcov_polactiv_1isdisk)

model_polactiv_1issozmedia_clust <- coeftest(model_polactiv_1issozmedia, vcov = clust_vcov_polactiv_1issozmedia)

model_polactiv_1isparty_clust <- coeftest(model_polactiv_1isparty, vcov = clust_vcov_polactiv_1isparty)

model_polactiv_1iswear_clust <- coeftest(model_polactiv_1iswear, vcov = clust_vcov_polactiv_1iswear)

model_polactiv_1iscontact_clust <- coeftest(model_polactiv_1iscontact, vcov = clust_vcov_polactiv_1iscontact)

model_polactiv_1isdemo_clust <- coeftest(model_polactiv_1isdemo, vcov = clust_vcov_polactiv_1isdemo)

model_polactiv_1ispetit_clust <- coeftest(model_polactiv_1ispetit, vcov = clust_vcov_polactiv_1ispetit)

model_polactiv_1iselec_clust <- coeftest(model_polactiv_1iselec, vcov = clust_vcov_polactiv_1iselec)

model_polactiv_1isboyc_clust <- coeftest(model_polactiv_1isboyc, vcov = clust_vcov_polactiv_1isboyc)

model_polactiv_1isnothing_clust <- coeftest(model_polactiv_1isnothing, vcov = clust_vcov_polactiv_1isnothing)


```



### print table _all



```{r}

#library(jtools)
#library(huxtable)


result_tab <- export_summs(
                  model_polactiv_1ismeing_clust, 
                  model_polactiv_1isdisk_clust,
                  model_polactiv_1issozmedia_clust,
                  model_polactiv_1isparty_clust,
                  model_polactiv_1iswear_clust,
                  model_polactiv_1iscontact_clust,
                  model_polactiv_1isdemo_clust,
                  model_polactiv_1ispetit_clust,
                  model_polactiv_1iselec_clust,
                  model_polactiv_1isboyc_clust,
                  model_polactiv_1isnothing_clust,
              #scale = TRUE,
              #robust = TRUE,
              coefs = c(
               "Conspiracy belief: immigration" = "cb_mig_num_resc",
               "Conspiracy belief: Covid-19" = "cb_covid_num_resc",
               "Political interest" = "polinterest_num",
               "Left-right self-positioning" = "leftright_num",
               "Consider democracy to be important" = "demzuf_allg_num_resc",
               "Satisfaction with democracy" = "demzuf_land_num_resc",
               "Political trust" = "INDEXmean_poltrust_7items_resc",
               "Populism" = "INDEXmean_pop_9items3dim",
               "Gender (1 = female)" = "gender_1isfemale",
               "Age" = "age",
               "Education level (1 = medium)" = "education_3grp_1ismed",
               "Education level (1 = high)" = "education_3grp_1ishigh",
               "Income (1 = medium)" = "income_3grp_1ismed",
               "Income (1 = high)" = "income_3grp_1ishigh",
               "Place of residence (1 = rural)" = "wohn_4grp_1island",
               "Place of residence (1 = town)" = "wohn_4grp_1istown",
               "Place of residence (1 = suburb)" = "wohn_4grp_1issuburb",
               "Country fixed-effects" = "gender_1isfemale",
               "Constant" = "(Intercept)"
               ),
              model.names = c("Private setting", "Public disc.", "Social network", "Polit. party", "Wear a badge", "Contact politician", "Demonstration", "Petition", "Election", "Boycott", "None")
             )


print(result_tab)

```


### pseudo-r2


```{r}

#library(pscl)

pseudo_r2_model_polactiv_1ismeing <- pR2(model_polactiv_1ismeing)
pseudo_r2_model_polactiv_1isdisk <- pR2(model_polactiv_1isdisk)
pseudo_r2_model_polactiv_1issozmedia <- pR2(model_polactiv_1issozmedia)
pseudo_r2_model_polactiv_1isparty <- pR2(model_polactiv_1isparty)
pseudo_r2_model_polactiv_1iswear <- pR2(model_polactiv_1iswear)
pseudo_r2_model_polactiv_1iscontact <- pR2(model_polactiv_1iscontact)
pseudo_r2_model_polactiv_1isdemo <- pR2(model_polactiv_1isdemo)
pseudo_r2_model_polactiv_1ispetit <- pR2(model_polactiv_1ispetit)
pseudo_r2_model_polactiv_1iselec <- pR2(model_polactiv_1iselec)
pseudo_r2_model_polactiv_1isboyc <- pR2(model_polactiv_1isboyc)
pseudo_r2_model_polactiv_1isnothing <- pR2(model_polactiv_1isnothing)

#print(pseudo_r2_model_polactiv_1isnothing)


```



### AME



```{r}
#library(margins)

var_list <- c("cb_mig_num_resc", "cb_covid_num_resc")

```



```{r}

margins(model_polactiv_1ismeing
        , vcov = clust_vcov_polactiv_1ismeing
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```

```{r}

margins(model_polactiv_1isdisk
        , vcov = clust_vcov_polactiv_1isdisk
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_polactiv_1issozmedia
        , vcov = clust_vcov_polactiv_1issozmedia
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_polactiv_1isparty
        , vcov = clust_vcov_polactiv_1isparty
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_polactiv_1iswear
        , vcov = clust_vcov_polactiv_1iswear
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_polactiv_1iscontact
        , vcov = clust_vcov_polactiv_1iscontact
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```




```{r}

margins(model_polactiv_1isdemo
        , vcov = clust_vcov_polactiv_1isdemo
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_polactiv_1ispetit
        , vcov = clust_vcov_polactiv_1ispetit
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```


```{r}

margins(model_polactiv_1iselec
        , vcov = clust_vcov_polactiv_1iselec
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```



```{r}

margins(model_polactiv_1isboyc
        , vcov = clust_vcov_polactiv_1isboyc
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```



```{r}

margins(model_polactiv_1isnothing
        , vcov = clust_vcov_polactiv_1isnothing
        , variables = var_list
        #, at = list(union = 0:1)
        ) %>%
  
  summary()

```



# -----------------------------------------
# -----------------------------------------
# -----------------------------------------



# [PLACE-BASED-IDENTITY]

## subset



```{r}

POLAR22_ident <- 
  subset(POLAR22, select=c(
                           
                           "cb_mig_num_resc",
                           #"cb2_war",
                           "cb_covid_num_resc",
                           #"cb4_clim",
                           
                           
                           "pbi_town_num_resc",
                           "pbi_region_num_resc",
                           "pbi_country_num_resc",
                           "pbi_europe_num_resc",
    
                           #"polinterest",
                           "polinterest_num",
                           "leftright_num",
    
                           "demzuf_allg_num_resc",
                           #"demzuf_land",
                           #"demzuf_land_num",
                           "demzuf_land_num_resc",
                           #"INDEXmean_demzuf_2items",
                           #"INDEXmean_poltrust_7items",
                           "INDEXmean_poltrust_7items_resc",
                           "INDEXmean_pop_9items3dim",
                           #"INDEXmean_pop_9items_MH",
                           
                           "gender_1isfemale",
                           "age",
    
                           #"education_3grp",
                           "education_3grp_1islow",
                           "education_3grp_1ismed",
                           "education_3grp_1ishigh",
    
                           #"income_3grp",
                           #"income_3grp_1islow",
                           "income_3grp_1ismed",
                           "income_3grp_1ishigh",
    
                           #"wohn_4grp",
                           "wohn_4grp_1iscity",
                           "wohn_4grp_1istown",
                           "wohn_4grp_1issuburb",
                           "wohn_4grp_1island",
    
                           
                           "country_factor",

                           "weight"))
                           


POLAR22_ident_nasraus <- POLAR22_ident %>%
  drop_na()



```


### model_pbi_town_num ~ cb_mig/cb_covid



```{r}
#library(estimatr)

model_pbi_town_num <- lm_robust(pbi_town_num_resc ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_ident_nasraus
                          , clusters = country_factor

                       )

summary(model_pbi_town_num)


```


### model_pbi_region_num ~ cb_mig/cb_covid


```{r}
#library(estimatr)

model_pbi_region_num <- lm_robust(pbi_region_num_resc ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_ident_nasraus
                          , clusters = country_factor

                       )

summary(model_pbi_region_num)


```

### model_pbi_country_num ~ cb_mig/cb_covid


```{r}
#library(estimatr)

model_pbi_country_num <- lm_robust(pbi_country_num_resc ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_ident_nasraus
                          , clusters = country_factor

                       )

summary(model_pbi_country_num)


```

### model_pbi_europe_num ~ cb_mig/cb_covid


```{r}
#library(estimatr)

model_pbi_europe_num <- lm_robust(pbi_europe_num_resc ~ 
                  
                           cb_mig_num_resc
                           + cb_covid_num_resc
                           
                           + demzuf_allg_num_resc
                           + demzuf_land_num_resc
                           + INDEXmean_poltrust_7items_resc
                           + INDEXmean_pop_9items3dim
                           
                           + gender_1isfemale
                           + age
                           + I(age^2)
                           + education_3grp_1ismed
                           + education_3grp_1ishigh
                           + income_3grp_1ismed
                           + income_3grp_1ishigh
                           + wohn_4grp_1istown
                           + wohn_4grp_1issuburb
                           + wohn_4grp_1island
                          
                           + polinterest_num
                           + leftright_num
                           
                           + country_factor
                           
                          , data = POLAR22_ident_nasraus
                          , clusters = country_factor

                       )

summary(model_pbi_europe_num)


```





### print table _all


```{r}

#library(jtools)
#library(huxtable)


result_tab <- export_summs(model_pbi_town_num, model_pbi_region_num, model_pbi_country_num, model_pbi_europe_num,
              #scale = TRUE,
              #robust = TRUE,
              coefs = c(
               "Conspiracy belief: immigration" = "cb_mig_num_resc",
               "Conspiracy belief: Covid-19" = "cb_covid_num_resc",
               "Political interest" = "polinterest_num",
               "Left-right self-positioning" = "leftright_num",
               "Consider democracy to be important" = "demzuf_allg_num_resc",
               "Satisfaction with democracy" = "demzuf_land_num_resc",
               "Political trust" = "INDEXmean_poltrust_7items_resc",
               "Populism" = "INDEXmean_pop_9items3dim",
               "Gender (1 = female)" = "gender_1isfemale",
               "Age" = "age",
               "Education level (1 = medium)" = "education_3grp_1ismed",
               "Education level (1 = high)" = "education_3grp_1ishigh",
               "Income (1 = medium)" = "income_3grp_1ismed",
               "Income (1 = high)" = "income_3grp_1ishigh",
               "Place of residence (1 = rural)" = "wohn_4grp_1island",
               "Place of residence (1 = town)" = "wohn_4grp_1istown",
               "Place of residence (1 = suburb)" = "wohn_4grp_1issuburb",
               "Country fixed-effects" = "gender_1isfemale",
               "Constant" = "(Intercept)"
               ),
              model.names = c("town or city", "region", "country", "Europe")
             )


print(result_tab)

```




# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------
# -----------------------------------------